/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("qx_car",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.Miyao.IServices;
using Orther.BLL.Miyao;
using Orther.Model.param;
using Project.Utils;
using VOL.Core.Filters;

namespace VOL.Miyao.Controllers
{
    public partial class qx_carController
    {
        private readonly Iqx_carService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;
        private CarBLL carBLL = new CarBLL();

        [ActivatorUtilitiesConstructor]
        public qx_carController(
            Iqx_carService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }


        [ApiActionPermission(Core.Enums.ActionPermissionOptions.Search)]
        [HttpGet, Route("GetPageDataZjc")]
        public ActionResult GetPageDataZjc(CarParam param, Pagination pagination)
        {
            TData<List<qx_car>> obj = carBLL.GetPageList(param, pagination);
            return JsonNormal(obj);
        }


        [ApiActionPermission(Core.Enums.ActionPermissionOptions.Search)]
        [HttpGet, Route("GetObjectJson")]
        public async Task<ActionResult> GetObjectJson(CarParam param)
        {
            TData<qx_car> obj = await carBLL.GetObject(param);
            return JsonNormal(obj);
        }

        [ApiActionPermission(Core.Enums.ActionPermissionOptions.Update)]
        [HttpPost, Route("SaveFormJson")]
        public async Task<ActionResult> SaveFormJson([FromBody] qx_car entity)
        {
            TData obj = await carBLL.SaveForm(entity);
            return JsonNormal(obj);
        }


        [ApiActionPermission(Core.Enums.ActionPermissionOptions.Delete)]
        [HttpGet, Route("DeleteFromJson")]
        public async Task<ActionResult> DeleteFromJson(Guid id)
        {
            TData obj = await carBLL.deleteFrom(id);
            return JsonNormal(obj);
        }



    }
}
